#include "relationgraphicsline.h"

#include "uml/relations/umlrelation.h"

RelationGraphicsLine::RelationGraphicsLine(QGraphicsItem *parent) :
    QGraphicsLineItem(parent)
{
    this->setAcceptHoverEvents(true);
    this->setFlags(QGraphicsItem::ItemIsSelectable);
}

void RelationGraphicsLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
    emit this->relationHoverEnter(event);
}

void RelationGraphicsLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
    emit this->relationHoverLeave(event);
}

void RelationGraphicsLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
    emit this->relationHoverMove(event);
}

void RelationGraphicsLine::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
    emit this->relationMouseDoubleClick(event);
}

void RelationGraphicsLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
    UmlRelation *relation = dynamic_cast<UmlRelation*>(this->parentItem());

    if (relation) {
        relation->contextMenuEvent(event);
    }
}
